<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/views/include/taglib.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<%@ include file="/views/include/nocachehead.jsp"%>
<title>${attraction.name}</title>
<style type="text/css">
.album_photo{width: 140px;height: 140px;background: url('${pageContext.request.contextPath}/img/albumback.gif') 0px 0px no-repeat;}
.album{padding-top:6px;padding-left:6px}
img {border: 0px;}
body {font-size: 12px}
</style>
</head>

<body>
	<%@ include file="/views/include/statusbar.jsp"%>
	<br>
	<br>
	<skyline:setSessionAttrToVar var="SESSION_USER" key="SESSION_USER"/>
	<div>
		<c:if test="${requestScope.type eq 'ALBUM' }">
			<div>
				<c:forEach items="${requestScope.albums}" var="album">
					<div>
						<div class="album_photo">
							<a title="<c:out value="${album.albumName}" />" href="${pageContext.request.contextPath}/album/view/${album.id }.html">
								<img alt="<skyline:summary length="17" value="${album.albumName}" />" class="album" src="${pageContext.request.contextPath}/image/${album.cover}.${album.coverExt}" />
							</a>
						</div>
						<div>
							<a title="<c:out value="${album.albumName}" />" href="${pageContext.request.contextPath}/album/view/${album.id }.html">
								<skyline:summary length="17" value="${album.albumName}" />
							</a>
							<div><span title="<c:out value="${album.place}" />"><skyline:summary length="17" value="${album.place}" /></span></div>
							<div><span title="<c:out value="${album.description}" />"><skyline:summary length="40" value="${album.description}" /></span></div>
							<span>${album.photoNum}张照片</span>
							<fmt:formatDate value="${album.createTime}" pattern="yyyy-MM-dd"/>创建
							<c:if test="${album.ownerId eq pageScope.SESSION_USER.id}">
								<div>
									<c:if test="${album.refed }">
										<a class="refed">已投寄</a>
									</c:if>
									<c:if test="${not album.refed }">
										<a href="#" onclick="postRef(this,'${album.id}','ALBUM');">投寄</a>
									</c:if>
								</div>
							</c:if>
						</div>
					</div>
					<c:if test="${status.index%4 eq 0}">
						<div class="clear"></div>
					</c:if>
				</c:forEach>
			</div>
		</c:if>
		
		
		<c:if test="${requestScope.type eq 'TRAVELNOTE' }">
			<div>
				<c:forEach var="article" items="${requestScope.articles}">
					<p><a href="<%=request.getContextPath()%>/article/view/${article.id}.html">${article.title}</a></p>
					<p>发表于:<fmt:formatDate value="${article.createTime}" type="both"/></p>
					<p><a class="articleContentA" href="<%=request.getContextPath()%>/article/view/${article.id}.html">${article.digest}......</a></p>
					<c:if test="${article.ownerId eq pageScope.SESSION_USER.id}">
						<div>
							<c:if test="${article.refed }">
								<a class="refed">已投寄</a>
							</c:if>
							<c:if test="${not article.refed }">
								<a href="#" onclick="postRef(this,'${article.id}','TRAVELNOTE');">投寄</a>
							</c:if>
						</div>
					</c:if>
				</c:forEach>
			</div>
		</c:if>
		
		
	</div>
	<div>
		<skyline:page url="${pageContext.request.contextPath}/attraction/ref/add/${requestScope.attraction.id}.html?type=${requestScope.type }" page="${requestScope.page}" maxSize="5" />
	</div>
	
	<c:set var="redirectUrl" value="${pageContext.request.contextPath}/attraction/ref/${requestScope.attraction.id }.html?curpage=${requestScope.page.curpage }%26type=${requestScope.type }"/>
	
	<script type="text/javascript">
	function postRef(obj,refId,type) {
		var _url = '${pageContext.request.contextPath}/attraction/ref/add/${requestScope.attraction.id}.html';
		var _data = "refId="+refId+"&type="+type;
		doAjax(_url,_data,function(data){
			if(data.logined) {
				if(data.success) {
					$(obj).html("已投寄").addClass("refed").removeAttr("onclick").removeAttr("href");
				} else {
					alert(data.errmsg);	
				}
			} else {
				alert(data.errmsg);
				return window.location=SKYLINE_DOMAIN+'/login.html?requestFrom=${redirectUrl}';
			}
		});
	}
	</script>
</body>
</html>